package com.manthano.security.user.service;

import java.util.Collection;

import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.core.Authentication;

import com.manthano.security.exception.AuthenticationException;

/**
 * @author LXMRX
 */
public interface UserService
{

	/**
	 * checks if there is an authentication for the current request
	 * 
	 * @return true if there is an authentication, false if not.
	 */
	boolean isAuthenticated();

	/**
	 * retrieve the current user, if authenticated
	 * 
	 * @return the authenticated {@link AbstractUser}
	 * @throws AuthenticationServiceException
	 *             if there is no authenticated user
	 */
	AbstractUser getAuthenticatedUser() throws AuthenticationException;

	/**
	 * login a user into the system.
	 * 
	 * @return the user, if login succeded
	 */
	AbstractUser login(Authentication authentication) throws AuthenticationException;

	/**
	 * logout the current user
	 */
	void logout();

	/**
	 * read all existing users
	 * 
	 * @return
	 */
	Collection<AbstractUser> getAllUsers();

	/**
	 * read all aviable roles
	 * 
	 * @return
	 */
	Collection<Role> getAllRoles();

}
